package com.gupao.bio;

import java.io.*;
import java.net.Socket;

public class BlockingClient {

    public static void main(String[] args) {

        try {
            // 建立连接
            Socket socket = new Socket("localhost",8080);
            // 向服务端写数据
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            bufferedWriter.write("我是客户端，收到请回答！！\n");
            bufferedWriter.flush();

            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String line = bufferedReader.readLine();
            System.out.println(line);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
